import * as echarts from "echarts";

type EChartsOption = echarts.EChartsOption;
type pieChartData = {
  value: number;
  name: string;
};
export default function setPeiChartOpt(opt: pieChartData[], title: string) {
  const pieChartOption: EChartsOption = {
    title: {
      text: title,
      left: "center",
      textStyle: {
        fontSize: 16,
        fontWeight: 400,
      },
    },
    toolbox: {
      show: true,
      feature: {},
    },
    tooltip: {
      trigger: "item",
    },
    legend: {
      orient: "vertical",
      left: "left",
    },
    series: [
      {
        name: title.slice(-2),
        type: "pie",
        radius: "50%",
        data: opt,
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)",
          },
        },
        label: {
          show: true,
          formatter: '{b}:{c}元'
        }
      },
    ],
  };

  return pieChartOption;
}
